package com.zhyl.demo.service.impl;

import com.zhyl.demo.entity.News;
import com.zhyl.demo.mapper.NewsMapper;
import com.zhyl.demo.service.NewsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;

@Service
public class NewsServiceImpl implements NewsService {
    private final NewsMapper newsMapper;
    @Autowired
    private NewsServiceImpl(NewsMapper newsMapper) {

        this.newsMapper = newsMapper;
    }

    @Override
    public ArrayList<News> list() {
      return newsMapper.list();
    }

    @Override
    public Boolean addNews(News news) {
        Integer i = newsMapper.addNews(news);
        return i>=0;

    }

    @Override
    public Boolean editNews(News news) {
        Integer i = newsMapper.editNews(news);
        return i>=0;
    }

    @Override
    public Boolean deleteNews(Integer id) {
        Integer i = newsMapper.deleteNews(id);
        return i>=0;
    }

    @Override
    public ArrayList<News> allList() {
        return newsMapper.allList();
    }
}
